/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jeffoldwork;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author Aurabolt
 */
public class SkinSelectPanel extends JPanel implements ActionListener {
    public String skinName;
    public String author;

    public Boolean active = false;

    public SkinSelectPanel(ImageIcon pic, String name, String auth)
    {
        super();
        skinName = name;
        author = auth;
        
        this.setLayout(new BorderLayout());
        JLabel label = new JLabel("");
        label.setIcon(pic);
        this.add(label, BorderLayout.NORTH);

        // Add Skin Name JLabel
        JLabel labelName = new JLabel(skinName);
        Font curFont = labelName.getFont();
        labelName.setFont(new Font(curFont.getFontName(), curFont.getStyle(), 16));
        this.add(labelName, BorderLayout.CENTER);

        // Add Skin Author JLabel
        JLabel labelAuthor = new JLabel(author);
        curFont = labelAuthor.getFont();
        labelAuthor.setFont(new Font(curFont.getFontName(), curFont.getStyle(), 16));
        this.add(labelAuthor, BorderLayout.SOUTH);

        // Mouse listener for clicks
        addMouseListener(new MouseAdapter() {
            @Override
          public void mouseReleased(MouseEvent me) {
            activate();
          }
        });
    }

    public void activate()
    {
        //Main.chooser.activate(skinName);
        active = true;
        this.setBackground(Color.yellow);
        Main.chooser.activator(skinName);
    }

    public void activate(boolean callActivator)
    {
        //Main.chooser.activate(skinName);
        active = true;
        this.setBackground(Color.yellow);

        if(callActivator)
            Main.chooser.activator(skinName);
    }

    public void deactivate()
    {
        this.setBackground(null);
        active = false;
    }

    public String getSkinName()
    {
        return skinName;
    }

    public String getSkinAuthor()
    {
        return author;
    }

    /*
    public void actionPerformed(ActionEvent e) {
        System.out.println("action");
        Main.chooser.activator();
        throw new UnsupportedOperationException("Not supported yet.");
    }
     *
     */

    public Boolean getActive() {
        return active;
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
